package model.calendar;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "calendar")
public class Calendar implements Serializable
{
	private static final long serialVersionUID = 5512856441254052612L;

	private static int i = 0;
	
	@XmlAttribute
	private String id = "";
	
	@XmlAttribute
	private String name;
	
	@XmlElement(name = "entry")
	private ArrayList<Entry> entries = new ArrayList<Entry>();
	
	public Calendar() {}
	
	public Calendar(String name)
	{
		i++;
		this.id = i + "";
		this.name = name;
	}
	
	public Calendar(String id, String name)
	{
		this.id = id;
		this.name = name;
	}
	
	public Entry createEntry(String number, String date, String daySchedule, String dayCalendar)
	{
		Entry entry = new Entry(number, date, daySchedule, dayCalendar);
		entries.add(entry);
		return entry;
	}
	
	public String toString()
	{
		String out = "\n";
		for (int i = 0; i < entries.size(); i++)
		{
			out += entries.get(i) + "\n";
		}
		return "Calendar id(" + id + ") -> Name: " + name + out;
	}

	public String getId()
	{
		return id;
	}

	public String getName()
	{
		return name;
	}

	public ArrayList<Entry> getEntries()
	{
		return entries;
	}
}